{"componentChunkName":"component---node-modules-rocketseat-gatsby-theme-docs-core-src-templates-docs-query-js","path":"/code-style/ManagedWithdrawRWA-MWR","result":{"data":{"mdx":{"id":"badd0180-25d7-5cca-8d20-cf6d2deb9c62","excerpt":"MWR-01C: Inefficient Hook Reads Type Severity Location Gas Optimization ManagedWithdrawRWA.sol:L106 ,  L116-L121 Description: The  ManagedWithdrawRWA…","fields":{"slug":"/code-style/ManagedWithdrawRWA-MWR/"},"frontmatter":{"title":"ManagedWithdrawRWA Code Style Findings","description":"Contains all the findings that relate to code style on the contract codebase","image":null,"disableTableOfContents":null},"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"ManagedWithdrawRWA Code Style Findings\",\n  \"description\": \"Contains all the findings that relate to code style on the contract codebase\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h2\", {\n    \"id\": \"span-idmwr-01cmwr-01c-inefficient-hook-readsspan\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#span-idmwr-01cmwr-01c-inefficient-hook-readsspan\",\n    \"aria-label\": \"span idmwr 01cmwr 01c inefficient hook readsspan permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), mdx(\"span\", {\n    id: \"MWR-01C\"\n  }, \"MWR-01C: Inefficient Hook Reads\")), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Type\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Severity\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Location\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"/reports/sova-network-fountfi-protocol-684adfa36579f5001821a219/appendix/finding-types#gas-optimization\"\n  }, \"Gas Optimization\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"img\", {\n    parentName: \"td\",\n    \"className\": \"o-severity o-informational\",\n    \"src\": \"https://omniscia.io/report-assets/informational.png\"\n  })), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L106\"\n  }, \"ManagedWithdrawRWA.sol:L106\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L116-L121\"\n  }, \"L116-L121\"))))), mdx(\"h3\", {\n    \"id\": \"description\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#description\",\n    \"aria-label\": \"description permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Description:\"), mdx(\"p\", null, \"The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L75-L131\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"ManagedWithdrawRWA::batchRedeemShares\")), \" function will repetitively read the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"opHooks\"), \" from storage for each redemption being processed.\"), mdx(\"h3\", {\n    \"id\": \"example\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#example\",\n    \"aria-label\": \"example permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Example:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-sol\",\n    \"metastring\": \"title=src/token/ManagedWithdrawRWA.sol highlight={2,12,13,14,15,16,17} lineNumbers=true lineOffset=104\",\n    \"title\": \"src/token/ManagedWithdrawRWA.sol\",\n    \"highlight\": \"{2,12,13,14,15,16,17}\",\n    \"lineNumbers\": \"true\",\n    \"lineOffset\": \"104\"\n  }, \"// Cache the OP_WITHDRAW hooks once to save gas / avoid stack depth issues\\nHookInfo[] storage opHooks = operationHooks[OP_WITHDRAW];\\n\\n// Execute each individual withdrawal (includes hooks)\\nfor (uint256 i; i < len; ++i) {\\n    uint256 userShares = shares[i];\\n    uint256 userAssets = assets[i];\\n    address recipient = to[i];\\n    address shareOwner = owner[i];\\n\\n    // Call hooks (same logic as in _withdraw)\\n    for (uint256 j; j < opHooks.length; ++j) {\\n        IHook.HookOutput memory hookOut =\\n            opHooks[j].hook.onBeforeWithdraw(address(this), strategy, userAssets, recipient, shareOwner);\\n        if (!hookOut.approved) revert HookCheckFailed(hookOut.reason);\\n        opHooks[j].hasProcessedOperations = true;\\n    }\\n\\n    // Accounting and transfers (mirrors _withdraw logic sans nonReentrant)\\n    if (strategy != shareOwner) _spendAllowance(shareOwner, strategy, userShares);\\n    _beforeWithdraw(userAssets, userShares);\\n    _burn(shareOwner, userShares);\\n\\n    SafeTransferLib.safeTransfer(asset(), recipient, userAssets);\\n    emit Withdraw(strategy, recipient, shareOwner, userAssets, userShares);\\n}\\n\")), mdx(\"h3\", {\n    \"id\": \"recommendation\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#recommendation\",\n    \"aria-label\": \"recommendation permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Recommendation:\"), mdx(\"p\", null, \"We advise all hooks to be loaded into \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"memory\"), \" once, ensuring that they can be re-used as needed per redemption efficiently.\"), mdx(\"h3\", {\n    \"id\": \"alleviation-e4d6885477438291b0d3ca477fab7e088522967b\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#alleviation-e4d6885477438291b0d3ca477fab7e088522967b\",\n    \"aria-label\": \"alleviation e4d6885477438291b0d3ca477fab7e088522967b permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):\"), mdx(\"p\", null, \"The code was updated to load all hooks into \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"memory\"), \" efficiently, addressing this exhibit.\"), mdx(ViewDiffButton, {\n    repoUrl: \"https://github.com/SovaNetwork/fountfi\",\n    mainHash: \"fca2fe922e699e8762410f40e249961b53c3bf92\",\n    fixHash: \"e4d6885477438291b0d3ca477fab7e088522967b\",\n    gitHubIssue: \"0\",\n    mdxType: \"ViewDiffButton\"\n  }), mdx(\"h2\", {\n    \"id\": \"span-idmwr-02cmwr-02c-potentially-incorrect-allowance-requirementspan\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#span-idmwr-02cmwr-02c-potentially-incorrect-allowance-requirementspan\",\n    \"aria-label\": \"span idmwr 02cmwr 02c potentially incorrect allowance requirementspan permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), mdx(\"span\", {\n    id: \"MWR-02C\"\n  }, \"MWR-02C: Potentially Incorrect Allowance Requirement\")), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Type\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Severity\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Location\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"/reports/sova-network-fountfi-protocol-684adfa36579f5001821a219/appendix/finding-types#gas-optimization\"\n  }, \"Gas Optimization\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"img\", {\n    parentName: \"td\",\n    \"className\": \"o-severity o-informational\",\n    \"src\": \"https://omniscia.io/report-assets/informational.png\"\n  })), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L52\"\n  }, \"ManagedWithdrawRWA.sol:L52\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L80\"\n  }, \"L80\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L124\"\n  }, \"L124\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L177\"\n  }, \"L177\"))))), mdx(\"h3\", {\n    \"id\": \"description-1\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#description-1\",\n    \"aria-label\": \"description 1 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Description:\"), mdx(\"p\", null, \"The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ManagedWithdrawRWA\"), \" contract will require an approval by any member that wishes to perform a withdrawal toward the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"strategy\"), \" which we consider non-standard and an inefficient approach as we can assume the strategy has performed adequate validation to ensure its caller is authorized by the member the withdrawal is being performed from.\"), mdx(\"h3\", {\n    \"id\": \"example-1\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#example-1\",\n    \"aria-label\": \"example 1 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Example:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-sol\",\n    \"metastring\": \"title=src/token/ManagedWithdrawRWA.sol highlight={58} lineNumbers=true lineOffset=66\",\n    \"title\": \"src/token/ManagedWithdrawRWA.sol\",\n    \"highlight\": \"{58}\",\n    \"lineNumbers\": \"true\",\n    \"lineOffset\": \"66\"\n  }, \"/**\\n * @notice Process a batch of user-requested withdrawals with minimum assets check\\n * @param shares The amount of shares to redeem\\n * @param to The address to send the assets to\\n * @param owner The owner of the shares\\n * @param minAssets The minimum amount of assets for each withdrawal\\n * @return assets The amount of assets received\\n */\\nfunction batchRedeemShares(\\n    uint256[] calldata shares,\\n    address[] calldata to,\\n    address[] calldata owner,\\n    uint256[] calldata minAssets\\n) external onlyStrategy nonReentrant returns (uint256[] memory assets) {\\n    // Validate array lengths\\n    uint256 len = shares.length;\\n    if (len != to.length || len != owner.length || len != minAssets.length) {\\n        revert InvalidArrayLengths();\\n    }\\n\\n    // Prepare memory array and accumulate total assets required\\n    assets = new uint256[](len);\\n    uint256 totalAssets;\\n\\n    for (uint256 i; i < len; ++i) {\\n        // Validate share amount for each owner\\n        if (shares[i] > maxRedeem(owner[i])) revert RedeemMoreThanMax();\\n\\n        uint256 amt = previewRedeem(shares[i]);\\n        if (amt < minAssets[i]) revert InsufficientOutputAssets();\\n\\n        assets[i] = amt;\\n        totalAssets += amt;\\n    }\\n\\n    // Pull all assets from the strategy in a single transfer\\n    _collect(totalAssets);\\n\\n    // Cache the OP_WITHDRAW hooks once to save gas / avoid stack depth issues\\n    HookInfo[] storage opHooks = operationHooks[OP_WITHDRAW];\\n\\n    // Execute each individual withdrawal (includes hooks)\\n    for (uint256 i; i < len; ++i) {\\n        uint256 userShares = shares[i];\\n        uint256 userAssets = assets[i];\\n        address recipient = to[i];\\n        address shareOwner = owner[i];\\n\\n        // Call hooks (same logic as in _withdraw)\\n        for (uint256 j; j < opHooks.length; ++j) {\\n            IHook.HookOutput memory hookOut =\\n                opHooks[j].hook.onBeforeWithdraw(address(this), strategy, userAssets, recipient, shareOwner);\\n            if (!hookOut.approved) revert HookCheckFailed(hookOut.reason);\\n            opHooks[j].hasProcessedOperations = true;\\n        }\\n\\n        // Accounting and transfers (mirrors _withdraw logic sans nonReentrant)\\n        if (strategy != shareOwner) _spendAllowance(shareOwner, strategy, userShares);\\n        _beforeWithdraw(userAssets, userShares);\\n        _burn(shareOwner, userShares);\\n\\n        SafeTransferLib.safeTransfer(asset(), recipient, userAssets);\\n        emit Withdraw(strategy, recipient, shareOwner, userAssets, userShares);\\n    }\\n}\\n\")), mdx(\"h3\", {\n    \"id\": \"recommendation-1\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#recommendation-1\",\n    \"aria-label\": \"recommendation 1 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Recommendation:\"), mdx(\"p\", null, \"We advise the withdrawal requirement to be omitted, optimizing the code's gas cost as well as user experience.\"), mdx(\"h3\", {\n    \"id\": \"alleviation-e4d6885477438291b0d3ca477fab7e088522967b-1\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#alleviation-e4d6885477438291b0d3ca477fab7e088522967b-1\",\n    \"aria-label\": \"alleviation e4d6885477438291b0d3ca477fab7e088522967b 1 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):\"), mdx(\"p\", null, \"The allowance requirement has been omitted as advised, optimizing the code's gas cost.\"), mdx(ViewDiffButton, {\n    repoUrl: \"https://github.com/SovaNetwork/fountfi\",\n    mainHash: \"fca2fe922e699e8762410f40e249961b53c3bf92\",\n    fixHash: \"e4d6885477438291b0d3ca477fab7e088522967b\",\n    gitHubIssue: \"0\",\n    mdxType: \"ViewDiffButton\"\n  }), mdx(\"h2\", {\n    \"id\": \"span-idmwr-03cmwr-03c-redundant-withdrawal-overridespan\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#span-idmwr-03cmwr-03c-redundant-withdrawal-overridespan\",\n    \"aria-label\": \"span idmwr 03cmwr 03c redundant withdrawal overridespan permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), mdx(\"span\", {\n    id: \"MWR-03C\"\n  }, \"MWR-03C: Redundant Withdrawal Override\")), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Type\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Severity\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Location\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"/reports/sova-network-fountfi-protocol-684adfa36579f5001821a219/appendix/finding-types#gas-optimization\"\n  }, \"Gas Optimization\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"img\", {\n    parentName: \"td\",\n    \"className\": \"o-severity o-informational\",\n    \"src\": \"https://omniscia.io/report-assets/informational.png\"\n  })), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L61\"\n  }, \"ManagedWithdrawRWA.sol:L61\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L158\"\n  }, \"L158\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L172-L200\"\n  }, \"L172-L200\"))))), mdx(\"h3\", {\n    \"id\": \"description-2\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#description-2\",\n    \"aria-label\": \"description 2 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Description:\"), mdx(\"p\", null, \"The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L172-L200\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"ManagedWithdrawRWA::_withdraw\")), \" function override is redundant as it executes the same statements as its parent \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"tRWA::_withdraw\"), \" implementation sans the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"tRWA::_collect\"), \" call which the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ManagedWithdrawRWA\"), \" replicates manually.\"), mdx(\"h3\", {\n    \"id\": \"example-2\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#example-2\",\n    \"aria-label\": \"example 2 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Example:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-sol\",\n    \"metastring\": \"title=src/token/ManagedWithdrawRWA.sol highlight={13,16,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55} lineNumbers=true lineOffset=145\",\n    \"title\": \"src/token/ManagedWithdrawRWA.sol\",\n    \"highlight\": \"{13,16,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55}\",\n    \"lineNumbers\": \"true\",\n    \"lineOffset\": \"145\"\n  }, \"/**\\n * @notice Redeem shares from the strategy - must be called by the manager\\n * @param shares The amount of shares to redeem\\n * @param to The address to send the assets to\\n * @param owner The owner of the shares\\n * @return assets The amount of assets received\\n */\\nfunction redeem(uint256 shares, address to, address owner) public override onlyStrategy returns (uint256 assets) {\\n    if (shares > maxRedeem(owner)) revert RedeemMoreThanMax();\\n    assets = previewRedeem(shares);\\n\\n    // Collect assets from strategy\\n    _collect(assets);\\n\\n    // User must token-approve strategy for withdrawal\\n    _withdraw(strategy, to, owner, assets, shares);\\n}\\n\\n/**\\n * @notice Override _withdraw to skip transferAssets since we already collected\\n * @param by Address initiating the withdrawal\\n * @param to Address receiving the assets\\n * @param owner Address that owns the shares\\n * @param assets Amount of assets to withdraw\\n * @param shares Amount of shares to burn\\n */\\nfunction _withdraw(address by, address to, address owner, uint256 assets, uint256 shares)\\n    internal\\n    override\\n    nonReentrant\\n{\\n    if (by != owner) _spendAllowance(owner, by, shares);\\n    _beforeWithdraw(assets, shares);\\n    _burn(owner, shares);\\n\\n    // Call hooks after state changes but before final transfer\\n    HookInfo[] storage opHooks = operationHooks[OP_WITHDRAW];\\n    for (uint256 i = 0; i < opHooks.length;) {\\n        IHook.HookOutput memory hookOutput = opHooks[i].hook.onBeforeWithdraw(address(this), by, assets, to, owner);\\n        if (!hookOutput.approved) {\\n            revert HookCheckFailed(hookOutput.reason);\\n        }\\n        // Mark hook as having processed operations\\n        opHooks[i].hasProcessedOperations = true;\\n\\n        unchecked {\\n            ++i;\\n        }\\n    }\\n\\n    // Transfer the assets to the recipient\\n    SafeTransferLib.safeTransfer(asset(), to, assets);\\n\\n    emit Withdraw(by, to, owner, assets, shares);\\n}\\n\")), mdx(\"h3\", {\n    \"id\": \"recommendation-2\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#recommendation-2\",\n    \"aria-label\": \"recommendation 2 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Recommendation:\"), mdx(\"p\", null, \"We advise the code to omit the manual \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"tRWA::_collect\"), \" calls and to remove the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://github.com/SovaNetwork/fountfi/blob/fca2fe922e699e8762410f40e249961b53c3bf92/src/token/ManagedWithdrawRWA.sol#L172-L200\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"ManagedWithdrawRWA::_withdraw\")), \" function implementation, optimizing the code's gas cost.\"), mdx(\"h3\", {\n    \"id\": \"alleviation-e4d6885477438291b0d3ca477fab7e088522967b-2\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#alleviation-e4d6885477438291b0d3ca477fab7e088522967b-2\",\n    \"aria-label\": \"alleviation e4d6885477438291b0d3ca477fab7e088522967b 2 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):\"), mdx(\"p\", null, \"The code was revised as advised, minimizing code redundancy.\"), mdx(ViewDiffButton, {\n    repoUrl: \"https://github.com/SovaNetwork/fountfi\",\n    mainHash: \"fca2fe922e699e8762410f40e249961b53c3bf92\",\n    fixHash: \"e4d6885477438291b0d3ca477fab7e088522967b\",\n    gitHubIssue: \"0\",\n    mdxType: \"ViewDiffButton\"\n  }));\n}\n;\nMDXContent.isMDXComponent = true;","headings":[{"depth":2,"value":"<span id=\"MWR-01C\">MWR-01C: Inefficient Hook Reads</span>"},{"depth":3,"value":"Description:"},{"depth":3,"value":"Example:"},{"depth":3,"value":"Recommendation:"},{"depth":3,"value":"Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):"},{"depth":2,"value":"<span id=\"MWR-02C\">MWR-02C: Potentially Incorrect Allowance Requirement</span>"},{"depth":3,"value":"Description:"},{"depth":3,"value":"Example:"},{"depth":3,"value":"Recommendation:"},{"depth":3,"value":"Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):"},{"depth":2,"value":"<span id=\"MWR-03C\">MWR-03C: Redundant Withdrawal Override</span>"},{"depth":3,"value":"Description:"},{"depth":3,"value":"Example:"},{"depth":3,"value":"Recommendation:"},{"depth":3,"value":"Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):"}]}},"pageContext":{"slug":"/code-style/ManagedWithdrawRWA-MWR/","prev":{"label":"LibRoleManaged.sol (LRM-C)","link":"/code-style/LibRoleManaged-LRM"},"next":{"label":"ManagedWithdrawRWAStrategy.sol (MWW-C)","link":"/code-style/ManagedWithdrawRWAStrategy-MWW"}}},"staticQueryHashes":["1954253342","2328931024","2501019404","973074209"]}